<style type="text/css">
    .select_list .on {
        color: #fff;
        background: #3399fe;
    }
</style>
<div class="select_con">
    <div>
        <div class="a1" onclick="getGameArea(this)" data-abir="<?php echo $gm; ?>"><?php echo $server ?></div>
        <div class="select_wr" id="areaServer"></div>
    </div>
    <div>
        <div class="a2"><?php echo $type ?></div>
        <div class="select_wr">
            <?php foreach ($types as $v): ?>
                <div onclick="getDataByType(this)" data-abri="<?php echo $v['abridge'] ?>"><?php echo $v['name'] ?></div>
            <?php endforeach ?>
        </div>
    </div>
    <div>
        <div class="a3">条件筛选</div>
        <div class="select_wr interval">
            <div>
                <div class="conditions">
                    <h4>交易身份</h4>
                   <div class="select_list">
                       <div onclick="setIdent(this)"  data-abri="buyer" <?php if($cr == 'buyer'){   ?> class="on" <?php } ?> >我要买</div>
                       <div onclick="setIdent(this)"  data-abri="seller" <?php if($cr == 'seller'){  ?> class="on" <?php } ?> >我要卖</div>
                   </div>
                </div>
                <!-- <div class="conditions">
                    <h4>价格区间（元）</h4>
                    <p>
                        <input type="text" placeholder="最低价">
                        ——
                        <input type="text" placeholder="最高价">
                    </p>
                </div> -->
                <div class="conditions">
                    <h4>比价平台</h4>
                    <ul>
                        <?php foreach ($platforms as $vo): ?>
                            <li>
                                <label class="<?php if($vo['is_check']){ echo 'checked'; } ?>" onclick="choosePlatform(this)" data-abri="<?php echo $vo['abridge'] ?>">
                                    <div class="check_box">
                                        <input type="checkbox" <?php if($vo['is_check']){ echo 'checked'; } ?>>
                                    </div>
                                    <?php echo $vo['name'] ?>
                                </label>
                            </li>
                        <?php endforeach ?>
                    </ul>
                </div>
                <div class="con_btn">
                    <button class="rest">重置</button>
                    <button onclick="postDataCheck()">确定</button>
                </div>
            </div>
        </div>
    </div>
</div>
<form id="searchForm">
   <input type="hidden" name="g" value="<?php echo $gm ?>">
   <input type="hidden" name="a" value="<?php echo $ar ?>">     
   <input type="hidden" name="t" value="<?php echo $ty ?>">     
   <input type="hidden" name="c" value="<?php echo $cr ?>">     
</form>
<script type="text/javascript">
    $(function(){
        $('.a2,.a3').click(function(){
            $(this).next('.select_wr').addClass('active');
        });
    });
    // 获取区信息
    function getGameArea(obj) {
        $(obj).next(".select_wr").addClass("active");
        var gm = $(obj).attr('data-abir');
        $.getJSON("<?php echo U('index/getAreaByGameAbri') ?>",{gm:gm},function(result){
            if(result.status) {
                $('#areaServer').html(result.data);
            }
        });
    }

    // 获取服信息
    function getGameServer(obj) {
        var area_id = $(obj).attr('data-id');
        $.getJSON("<?php echo U('index/getServerByAreaId') ?>",{area_id:area_id},function(result){
            if(result.status) {
                $('#areaServer').html(result.data);
            }
        });
    }

    // 访问接口
    function getGameType(obj) {
        $(".a1").text($(obj).text());
        $(obj).parent(".select_wr").removeClass('active');
        $("input[name='a']").val($(obj).attr('data-abri'));
        getData();
    }


    function getDataByType(obj) {
        $(".a2").text($(obj).text());
        $(obj).parent(".select_wr").removeClass('active');
        $("input[name='t']").val($(obj).attr('data-abri'));
        getData();
    }

    function setIdent(obj) {
        $(obj).addClass('on').siblings().removeClass('on');
        $("input[name='c']").val($(obj).attr('data-abri'));
    }

    function postDataCheck() {
        $(".interval").removeClass('active');
        getData();
    }

    //设置平台cookie
    function choosePlatform(obj) {
        var selected = 0;
        var abridge  = $(obj).attr('data-abri');
        if($(obj).find("input[type='checkbox']").prop('checked')){
            $(obj).addClass('checked');
            selected = 1;
        }else{
            $(obj).removeClass('checked');
        }
        $.getJSON("<?php echo U('index/setPlatCookie') ?>" , {is_check:selected,abridge:abridge});
    }
</script>